<?php
/**
 * Introduction: 售后问题类型
 * @author: 杨陈鹏
 * @date: 2016/4/1 08:42
 * @email: yangchenpeng@cdlinglu.com
 *
 */

namespace Admin\Controller\AfterSales;


use Common\Controller\Admin\CommonController;

class ProblemTypeController extends CommonController
{

    /**
     * Introduction: 售后问题类型添加
     * @author: 杨陈鹏
     * @date: 2016/4/1 08:42
     * @email: yangchenpeng@cdlinglu.com
     *
     */
    public function create()
    {

        $data = I('post.data');

        if ($data) {

            $logic = D('Common/AfterSales','Logic');

            $this->ajaxReturn($logic::createProblem($data));

        } else {

            $this->display();

        }


    }
    /**
     * Introduction: 售后问题类型列表
     * @author: 杨陈鹏
     * @date: 2016/4/1 08:42
     * @email: yangchenpeng@cdlinglu.com
     *
     */
    public function lists()
    {

        $logic = D('Common/AfterSales','Logic');

        $data = $logic::problemLists($this->page,$this->nums);

        if($data['code'] == 300)
            exit('<h1 style="font-size: 25px; text-align: center; margin-top: 50px">'.$data["msg"].'</h1>');

        $this->data = $data['data'];

        $this->display();

    }
    /**
     * Introduction: 修改售后问题类型
     * @author: 杨陈鹏
     * @date: 2016/4/1 08:42
     * @email: yangchenpeng@cdlinglu.com
     *
     */
    public function update()
    {

        $logic = D('Common/AfterSales','Logic');

        $data = I('post.data');

        if ($data['action'] == 'template') {

            $this->data = $logic::$model_type->where(['id' => $data['id']])->find();

            $this->display();

        } else {


            $this->ajaxReturn($logic::problemUpdate($data));


        }


    }
    /**
     * Introduction: 删除售后类型
     * @author: 杨陈鹏
     * @date: 2016/4/1 08:42
     * @email: yangchenpeng@cdlinglu.com
     *
     */
    public function delete()
    {

        $data = I('post.data');

        $logic = D('Common/AfterSales','Logic');

        $this->ajaxReturn($logic::problemDel($data));

    }
}